package com.wxz.gblw.cjg.controller;

import com.alibaba.fastjson.JSON;
import com.wxz.gblw.cjg.common.Result;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: xiangzhong.wang
 * @date: 2020/1/5 21:19
 */
@RestController
@RequestMapping("/user")
public class UserController {

    /**
     * 登录
     * @param params
     * @return
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public Object login(@RequestBody Map<String, String> params){
        System.out.println("参数=================="+ JSON.toJSONString(params));

        Result result = new Result();

        Map<String,Object> map = new HashMap<>();
        map.put("token","GBLW-CJG-2020setwetwet124215125");
        result.setData(map);
        return result;
    }

    /**
     * 用户信息
     * @param token
     * @return
     */
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public Object info(@RequestParam String token){
        System.out.println("参数用户："+token);
        Result result = new Result();

        Map<String,Object> map = new HashMap<>();

        List<String> roles = new ArrayList<>();
        roles.add("admin");
        map.put("roles",roles);
        map.put("introduction","我是超级管理员");
        map.put("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        map.put("name","超级管理员");
        result.setData(map);
        return result;
    }

    /**
     * 退出
     * @return
     */
    @RequestMapping(value = "/logout", method = RequestMethod.POST)
    public Object logout(){
        Result result = new Result();
        result.setData("success");
        return result;
    }

}
